CSharpTest.Net
StreamCache Constructor(IFactory<Stream>)
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > StreamCache Class > StreamCache Constructor : StreamCache Constructor(IFactory<Stream>)

streamFactory

Glossary Item Box

Constructs the stream cache allowing one stream per thread

Syntax

Visual Basic (Declaration) 
Public Function New( _
   ByVal streamFactory As IFactory(Of Stream) _
)
C# 
public StreamCache( 
   IFactory<Stream> streamFactory
)

Parameters

streamFactory

Example

Library/Library.Test/TestStreamCache.cs

C#Copy Code
Stream stream;
using (TempFile tempFile = new TempFile())
{
    using (StreamCache cache = new StreamCache(new FileStreamFactory(tempFile.TempPath, FileMode.Open)))
    {
        using (stream = cache.Open())
        {
            stream.SetLength(100);
            stream.WriteByte(1);
        }
    }

    Assert.AreEqual(100, tempFile.Length);
    using (stream = tempFile.Open())
        Assert.AreEqual(1, stream.ReadByte());
}
VB.NETCopy Code
Dim stream As Stream
Using tempFile As New TempFile()
    Using cache As New StreamCache(New FileStreamFactory(tempFile.TempPath, FileMode.Open))
        Using stream = cache.Open()
            stream.SetLength(100)
            stream.WriteByte(1)
        End Using
    End Using

    Assert.AreEqual(100, tempFile.Length)
    Using stream = tempFile.Open()
        Assert.AreEqual(1, stream.ReadByte())
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys